using System;
using System.Collections.Generic;
using System.Text;
using PetShop.Domain.Model;


namespace PetShop.Domain.Factories
{
    public class OrderFactory
    {
        public static Order Create(Account account, CreditCardInfo creditcard, AddressInfo billingAddress, AddressInfo shippingAddress, CartInfo cart)
        {
            var newOrder = new Order();
            newOrder.User = account;
            newOrder.CreditCard = creditcard;
            newOrder.BillingAddress = billingAddress;
            newOrder.ShippingAddress = shippingAddress;

            //add cartInfo to order
            foreach (var cartItem in cart.Items)
            {

                newOrder.AddLineItemInfo(cartItem.Item, cartItem.Quantity);

            }
            newOrder.OrderTotal = cart.Total;
            newOrder.OrderDate = DateTime.Now;
            return newOrder;
        }
    }
}
